package cn.itcast.controller;

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {
    @Autowired
    protected HttpServletRequest request;
    @Autowired
    protected HttpServletResponse response;
    @Autowired
    protected HttpSession session;

    public User getUser() {
        return (User) session.getAttribute("loginUser");
    }

    // 提供获取用户id和name的方法
    public String getCompanyId() {
        if (getUser() == null) {
            return null;
        } else {
            return getUser().getCompanyId();
        }
    }

    public String getCompanyName() {
        if (getUser() == null) {
            return null;
        } else {
            return getUser().getCompanyName();
        }
    }
}
